package com.csw.compose.ui.module.component.base

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Button
import androidx.compose.material3.ElevatedButton
import androidx.compose.material3.FilledTonalButton
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.csw.compose.theme.pagePadding
import com.csw.compose.ui.Destination
import com.csw.compose.ui.components.BodyText
import com.csw.compose.ui.components.LabelText
import com.csw.compose.ui.components.NormalSpacer
import com.csw.compose.ui.components.PrimaryTitle
import com.csw.compose.ui.components.UlItem
import com.csw.compose.ui.module.BasePage

@Preview
@Composable
fun ButtonPagePreview() {
    BasePage({}, "按钮（Button）") {
        ButtonPage()
    }
}

class ButtonPageData {
    companion object : Destination("ButtonPage")
}

/**
 *[参考](https://developer.android.google.cn/develop/ui/compose/components/button?hl=zh-cn)
 */
@Composable
fun ButtonPage() {
    Column(
        modifier = Modifier
            .padding(horizontal = pagePadding)
            .verticalScroll(rememberScrollState())
    ) {
        PrimaryTitle("简介")
        BodyText("Compose的按钮比View的自由很多，主要定义了背景与点击变化，内容则完全可以自定义")
        NormalSpacer()
        Button({}) { Text("Filled") }
        UlItem("Button")
        LabelText("默认按钮，以主题色填充")

        NormalSpacer()
        FilledTonalButton({}) { Text("Tonal") }
        UlItem("FilledTonalButton")
        LabelText("主题色的弱化按钮")

        NormalSpacer()
        OutlinedButton({}) { Text("Outlined") }
        UlItem("OutlinedButton")
        LabelText("轮廓按钮")

        NormalSpacer()
        ElevatedButton({}) { Text("Elevated") }
        UlItem("ElevatedButton")
        LabelText("突起按钮(实际每个按钮都可以设置海拔高度)")

        NormalSpacer()
        TextButton({}) { Text("Text") }
        UlItem("TextButton")
        LabelText("文本按钮")
    }
}